package com.haha.qqchannelbot.config;

import io.netty.channel.ChannelOption;
import io.netty.handler.timeout.ReadTimeoutHandler;
import org.springframework.http.client.reactive.ReactorClientHttpConnector;

import java.time.Duration;

import org.springframework.web.reactive.function.client.WebClient;
import reactor.netty.http.client.HttpClient;

public class HttpClientConfig {


    public static final Integer connectionTimeout = 60000;
    public static final long requestTimeout = 30000;
    public static final int readTimeout = 300000;
    HttpClient httpClient =
            HttpClient.create()
                    .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectionTimeout)
                    .responseTimeout(Duration.ofMillis(requestTimeout))
                    .doOnConnected(conn -> conn.addHandlerLast(new ReadTimeoutHandler(readTimeout)));

    WebClient client =
            WebClient.builder().clientConnector(new ReactorClientHttpConnector(httpClient)).build();

}
